Skip to content

feat: Support images in tool responses - #1589

Closed
jgontrum wants to merge 1 commit into
anomalyco:devfrom
jgontrum:dev
Closed

jgontrum wants to merge 1 commit into
anomalyco:devfrom
jgontrum:dev

Conversation

@jgontrum

@jgontrum jgontrum commented Aug 4, 2025

Copy link
Copy Markdown

While opencode can send images as user messages when we directly reference an image file, or drag-and-drop it, it wasn't able to analyze images programmatically.

By using multi-part tool responses, we can now let the read tool read an image and send it as a tool response. The same works for MCP servers returning images. Background: https://ai-sdk.dev/docs/foundations/prompts#multi-modal-tool-results

Note: As per the AI SDK, this is an experimental feature only supported by Anthropic.

- The read tool can now read images and return them as base64 string
- toModelOutput returns images to the LLM
- MCP servers can now also return images to the LLM
.join("\n\n")

return {
output,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the output string somewhere else, or could we use it to return the JSON response to be used in the toModelOutput function?

@rektide

rektide commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

@jgontrum what is the status here? I see a number of merged PR's that share seemingly some overlap? Is this still needed?

@jgontrum

Copy link
Copy Markdown
Author

@rektide tbh, no clue. I created this PR over half a year ago and stopped using OpenCode a while ago. If this is already implemented, please just close the PR

@vsorrokin vsorrokin left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It enables ability see the images in the session's chat window, right? Then it's still relevant

@rekram1-node

Copy link
Copy Markdown
Contributor

closing since this has been addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants